package com.buddy.design.pattern._10observer.advice;

import java.util.Observable;

/**
 * JDK提供的观察者实现方式
 */
public class Gper extends Observable{

    private String name = "Gper生态圈";

    private static Gper INSTANCE = null;

    private Gper(){

    }

    public static Gper getInstance(){
        if (null == INSTANCE){
            INSTANCE = new Gper();
        }
        return INSTANCE;
    }

    public String getName() {
        return name;
    }

    public void publishQuestion(Question question){
        System.out.println(question.getUserName()+"在"+this.name+"上提交了一个问题。");
        setChanged();
        notifyObservers(question);
    }
}
